<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>条件渲染</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
    <!-- 准备一个容器 -->
    <!-- 使用v-show 条件渲染 -->
    <div id="root" v-show="person.show">
        姓名：{{person.name}}
        <hr>
        <button v-if="str === 'A'">A按钮</button>
        <button v-else-if="str === 'B'">B按钮</button>
        <button v-else-if="str === 'C'">C按钮</button>
        <button v-else>什么都不是的按钮</button> <br>
        <button @click="changeStr">点此切换按钮~~</button>
        
    </div>

    

    <script type="text/javascript">
        new Vue({
            el:'#root',
            data(){
                return{
                    str:'A',
                    person:{
                        name:'张三',
                        show:true
                    }
                }
            },
            methods: {
              changeStr(){
                let arr = ['A','B','C','N/A']
                let idx = Math.floor(Math.random()*4)
                this.str = arr[idx]
              }  
            },
        })
    </script>
</body>

</html>